package com.dream.keigezhushou.Activity.Fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.dream.keigezhushou.Activity.Uiutils.StringUtils;
import com.dream.keigezhushou.Activity.Uiutils.UiUtils;
import com.dream.keigezhushou.Activity.bean.SingInfo;
import com.dream.keigezhushou.Activity.kege.acty.ChorusListActivity;
import com.dream.keigezhushou.Activity.kege.acty.SingingDetailActivity;
import com.dream.keigezhushou.Activity.kege.adapter.MySingingAdapter;
import com.dream.keigezhushou.R;
import com.handmark.pulltorefresh.library.PullToRefreshListView;

import java.util.ArrayList;

/**
 * 我的合唱
 */
public class MySingingFragment extends Fragment {
    private ArrayList<SingInfo> mList = new ArrayList<>();
    private PullToRefreshListView mMPullToRefreshListView;
    private ListView mListlv;
    private MySingingAdapter adapter;


    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initData();
        //getDataFromService();   获取网络数据并解析
        // 加载动画
        //设置上拉刷新重新请求网络数据  更新adapter?
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mMPullToRefreshListView = (PullToRefreshListView) UiUtils.inflateView(R.layout.singfragmentlayout);
        mListlv = mMPullToRefreshListView.getRefreshableView();

        adapter = new MySingingAdapter(getContext());
        mListlv.setAdapter(adapter);


        adapter.setItemOnClickListening(new MySingingAdapter.ItemOnClickListening() {
            @Override
            public void itemClick(int postion) {

                Intent intent=new Intent();
                intent.putExtra(StringUtils.KEGESTATE,"参与列表");
                intent.setClass(getContext(), SingingDetailActivity.class);
                startActivity(intent);

            }


            @Override
            public void singingJoinClick(int postion) {
                Intent intent=new Intent();
                intent.setClass(getContext(), ChorusListActivity.class);
                startActivity(intent);
            }
        });

        return mMPullToRefreshListView;

    }

    private void initData() {


    }






}
